package com.android.common;

import com.android.act.ReportWebActivity;

import android.content.Context;
import android.os.Handler;
import android.webkit.WebView;
import android.widget.Toast;

public class JsInterface {

	private WebView mWebView;
	final Handler handler = new Handler();
	Context ctx;

	public JsInterface(WebView mWebView, Context ctx2) {

		this.mWebView = mWebView;
		this.ctx = ctx2;
	}

	/**
	 * js接口
	 */

	public void backHistory() {
		handler.post(new Runnable() {
			public void run() {

				mWebView.goBack();
			}
		});
	}

	// 签到
	public void ReportOn() {
		handler.post(new Runnable() { //
			public void run() {
				// Toast.makeText(
				// ctx,
				// "您选择了签到功能：gps信息为lat:" + Common.lat + ",lon:"
				// + Common.lon, Toast.LENGTH_LONG).show();
				// mWebView.loadUrl("javascript: showGps('" + Common.lat +
				// ",lon:"
				// + Common.lon + "')");

				Toast.makeText(ctx, "您选择了签到功能 ", Toast.LENGTH_LONG).show();
				mWebView.loadUrl("javascript:reportOnCallback('"
						+ Common.address + "','" + Common.lat + "','"
						+ Common.lon + "')");

			}

		});
	}

	// 签退
	public void ReportOff() {
		handler.post(new Runnable() { //
			public void run() {
				Toast.makeText(ctx, "您选择了签退功能", Toast.LENGTH_LONG).show();
				mWebView.loadUrl("javascript:reportOffCallback('" + Common.address +"','"+Common.lat+"','"+Common.lon+"')");
			}
		});
	}

}